package o;

import android.os.Bundle;
import android.os.IBinder;
import android.os.IInterface;
import android.os.Parcelable;
import com.huawei.appgallery.parcelable.TypeException;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

enum cqc {
    Parcelable,
    Binder,
    StringList,
    List,
    Bundle,
    ParcelableArray,
    StringArray,
    ByteArray,
    Interface,
    IntArray,
    Integer,
    Long,
    Boolean,
    Float,
    Double,
    ᐝॱ,
    HashMap;

    static cqc ˏ(Field field) {
        Class type = field.getType();
        cqc ˋ = ˋ(type);
        if (ˋ != null) {
            return ˋ;
        }
        ˋ = ˎ(type);
        if (ˋ != null) {
            return ˋ;
        }
        if (HashMap.class.isAssignableFrom(type)) {
            return HashMap;
        }
        if (Bundle.class.isAssignableFrom(type)) {
            return Bundle;
        }
        if (Parcelable.class.isAssignableFrom(type)) {
            return Parcelable;
        }
        if (IBinder.class.isAssignableFrom(type)) {
            return Binder;
        }
        if (IInterface.class.isAssignableFrom(type)) {
            return Interface;
        }
        ˋ = ˊ(field, type);
        if (ˋ != null) {
            return ˋ;
        }
        throw new TypeException("Type is not yet usable with ParcelUtil: " + type);
    }

    private static cqc ˊ(Field field, Class cls) {
        if (cls != List.class && cls != ArrayList.class) {
            return null;
        }
        Type genericType = field.getGenericType();
        if (genericType instanceof ParameterizedType) {
            ParameterizedType parameterizedType = (ParameterizedType) genericType;
            if (parameterizedType.getActualTypeArguments().length == 1 && parameterizedType.getActualTypeArguments()[0] == String.class) {
                return StringList;
            }
        }
        return List;
    }

    private static cqc ˎ(Class cls) {
        if (cls.isArray() && Parcelable.class.isAssignableFrom(cls.getComponentType())) {
            return ParcelableArray;
        }
        if (cls.isArray() && String.class.isAssignableFrom(cls.getComponentType())) {
            return StringArray;
        }
        if (cls.isArray() && Byte.TYPE.isAssignableFrom(cls.getComponentType())) {
            return ByteArray;
        }
        if (cls.isArray() && Integer.TYPE.isAssignableFrom(cls.getComponentType())) {
            return IntArray;
        }
        return null;
    }

    private static cqc ˋ(Class cls) {
        if (cls == Integer.TYPE || cls == Integer.class) {
            return Integer;
        }
        if (cls == Boolean.TYPE || cls == Boolean.class) {
            return Boolean;
        }
        if (cls == Long.TYPE || cls == Long.class) {
            return Long;
        }
        if (cls == Float.TYPE || cls == Float.class) {
            return Float;
        }
        if (cls == Double.TYPE || cls == Double.class) {
            return Double;
        }
        if (cls == String.class) {
            return ᐝॱ;
        }
        return null;
    }
}
